<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>清除月份计算</title>
</head>
<body>
<div ng-app="RestatisticsApp" ng-controller="RestatisticsCtrl">
    <div class="row">
        <div class="col-md-6">
            <div class="col-md-2">
                <label>选择月份</label>
            </div>
            <div class="col-md-3">
                <input class="form-control" type="text"  id="datetimepicker" readonly>
            </div>
            <div class="col-md-3">
                <a class="btn btn-sm btn-primary" ng-click="doClear()" id="confireClear">确认清除</a><br/>
                <%--<a class="btn btn-sm btn-primary" ng-click="rePullData()" id="rePullLogisticsData">运单数据重拉</a>--%>
            </div>
            </div>
    </div>
</div>
<%--<script>
    $(function () {
        $("#rePullLogisticsData").hide();
        $("#rePullLogisticsData").attr('disabled',true);
    });
</script>--%>

<script>
    var config = {
        timmer:{
            baseUrl:"http://localhost:8080/timmer",
            jsessionid:"",
            triggerCalculate:"/job/triggerCalculate"
        }
    };
    angular.module('RestatisticsApp',[])
           .controller('RestatisticsCtrl', function($scope){
                $("#datetimepicker").datetimepicker({
                    startView:'year',
                    viewSelect:'year',
                    minView:'year',
                    format:'yyyy-mm',
                    autoclose: true,
                    todayBtn: true,
                    pickerPosition: "bottom-left"
                });
               $scope.doClear=function () {
                   $("#confireClear").attr('disabled',true);
                   var value = $("#datetimepicker").val();
                   $.ajax({
                       url:'report/restatistics/clearandcalculate',
                       data:{date:value},
                       type:'post',
                       async:false,
                       success:function (result) {
                           if (result.code=='0000'){
                               toastr.success("清除成功");
                               $("#confireClear").attr('disabled',false);
                               /*$("#rePullLogisticsData").show();
                               $("#rePullLogisticsData").attr('disabled',false);*/
                           }else {
                               toastr.error("清除失败,"+result.msg);
                               $("#confireClear").attr('disabled',false);

                           }
                       },
                       error:function () {
                           toastr.error("服务器异常");
                           $("#confireClear").attr('disabled',false);

                       }
                   })
               }
              /* $scope.rePullData = function () {
                   $.ajax({
                       url:'./system/menu/getTimmerBaseUrl',
                       type:'get',
                       async:false,
                       success:function (result) {
                           config.timmer.baseUrl = result.data.baseUrl;
                           config.timmer.jsessionid= result.data.JSESSIONID;
                       }
                   })
                   if(config.timmer.jsessionid){
                       $("#rePullLogisticsData").attr('disabled',true);
                       var month = $("#datetimepicker").val();
                       $.ajax({
                           url:config.timmer.baseUrl+config.timmer.triggerCalculate,
                           data:{backendSessionId:config.timmer.jsessionid,month:month},
                           type:'get',
                           success:function (result) {
                               if (result.code=='0000'){
                                   toastr.success("重拉成功！");
                                   $("#rePullLogisticsData").attr('disabled',false);
                               }else {
                                   toastr.error("重拉失败！,"+ result.msg);
                                   $("#rePullLogisticsData").attr('disabled',false);
                               }
                           },
                           error:function () {
                               toastr.error("服务器异常");
                               $("#rePullLogisticsData").attr('disabled',false);
                           }
                       })
                   }
               }*/
            });
</script>
</body>
</html>
